using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Net;
using System.Web;
using System.Threading;

namespace _1
{
    public partial class Form1 : Form
    {

        string keyWords;
        public Form1()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {
            keyWords = this.textBox1.Text;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string url = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=" + System.Web.HttpUtility.UrlEncode(keyWords, Encoding.GetEncoding("GB2312"));
            Crawler crawler = new Crawler();
            crawler.url = url;
            Thread thread = new Thread(crawler.Crawl);
            thread.Start();
            thread.Join();


            this.textBox2.AppendText(crawler.html);
        }
    }
}
